package com.gaoqi.mq.Hello;


import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * 模拟rabbitMQ hello 工作模式 消费者
 */
//将该类托管于 spring ioc 容器
@Component

//该注解可以写在方法上
//设置监听队列 (可以在该注解内设置 队列名 队列持久化 队列独占  是否删除队列 "值都为字符串")
//@RabbitListener(queuesToDeclare = @Queue("hello"))
@RabbitListener(queuesToDeclare = @Queue(name = "hello",durable = "false"))
//@RabbitListener(queuesToDeclare = @Queue(value = "hello",declare = "false",autoDelete = "false",exclusive = "false"))

//打印日志
@Slf4j
public class HelloConsumer1 {

    @RabbitHandler
    public void receiveMessageOfHello(String message){
        log.info("hello-消费者1-接收消息:{}",message);
    }
}
